<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/2/14
  Time: 16:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<% String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %>
<html>
<head>
    <title>评论列表</title>
    <base href="<%=basePath%>">
    <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/bs.css"/>

    <script type="text/javascript">

        function deleteUser(commentId){

            if(confirm("是否删除") ){

            $.post("/comment/delete",{"commentId":commentId},function(result){
                alert(result.message);
            });
            }
        }

        function editUser(commentId){
            location.href="<%=basePath%>comment/update/"+commentId;
        }


    </script>


</head>
<body>
<div class="container" style="border: 1px solid #CCCCCC;height: 1000px;">

    <div style="height:100px;border-bottom: 1px solid #CCCCCC;padding-top:30px;margin-bottom: 10px">
        <h2 class="h2">评论管理</h2>
    </div>

    <table class="table table-hover">
        <caption>评论列表</caption>
        <thead>
        <tr>
            <th>序号</th>
            <th>用户名</th>
            <th>图书标题</th>
            <th>评论内容</th>
            <th>评论日期</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${comments}" var="comment" varStatus="vs">
            <tr>
                <td>${vs.count}</td>
                <td>${comment.username}</td>
                <td>${fn:substring(comment.bookTitle,0,10)}</td>
                <td>${fn:substring(comment.content,0,10)}</td>
                <td><fmt:formatDate value="${comment.date}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td>${comment.flag==1 ? "通过审核":(comment.flag == 0?"<span style='color:red'>未审核</span>":"未通过审核")}</td>

                <td>
                    <button type="button" class="btn btn-xs btn-info" onclick="editUser(${comment.comment_id})">
                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                    </button>
                    <button type="button" class="btn btn-xs btn-danger" onclick="deleteUser(${comment.comment_id})">
                        <span class='glyphicon glyphicon-remove'></span> 删除
                    </button>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

</div>



</body>
</html>
